
package cn.sylinx.web.util;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class PackageUtil {

	public static Set<String> getPackageClass(String pkg) {

		Set<String> clzSets = new HashSet<>();
		ClasspathResourceScanner cp = new ClasspathResourceScanner(pkg, ".class", true);

		List<String> rList = null;
		try {
			rList = cp.getResourceNameList();
		} catch (Exception e) {
		}

		if (rList == null) {
			rList = new ArrayList<String>();
		}

		for (String rs : rList) {
			String pt1 = rs.replaceAll("/", "\\.");
			int index = pt1.lastIndexOf(".class");
			pt1 = pt1.substring(0, index);
			clzSets.add(pt1);
		}

		return clzSets;
	}
}
